package com.ld.wms.business.locker.controller;


import com.ld.wms.business.chat.vo.resp.IndexQuantityDataRespVo;
import com.ld.wms.business.locker.service.LockerService;
import com.ld.wms.business.locker.vo.req.LockerExtReqVo;
import com.ld.wms.business.locker.vo.req.LockerReqVo;
import com.ld.wms.business.locker.vo.resp.LockerExtRespVo;
import com.ld.wms.business.locker.vo.resp.LockerRespVo;
import com.ld.wms.common.ResultResponse;
import com.ld.wms.common.vo.GeneratePageListVo;
import com.ld.wms.common.vo.PrimaryKeyReqVo;
import com.ld.wms.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 智能柜表 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2025-03-28
 */
@Slf4j
@Tag(name = "智能柜体相关接口")
@RestController
public class LockerController {


    @Autowired
    private LockerService lockerService;

    @GetMapping("/api/wms/locker/getPageList")
    @Operation(summary = "智能柜列表")
    public ResultResponse<GeneratePageListVo<LockerRespVo>> getPageList(
            @Parameter(description = "当前页数") @RequestParam(defaultValue = "1") Integer current,
            @Parameter(description = "每页展示条数") @RequestParam(defaultValue = "10") Integer size
    ) {
        GeneratePageListVo<LockerRespVo> pageList = lockerService.getPageList(current, size);
        return ResultResponse.success(pageList);
    }

    @GetMapping("/api/wms/locker/getById")
    @Operation(summary = "获取智能柜详细")
    public ResultResponse<LockerRespVo> getById(
            @Parameter(description = "智能柜主键id") @RequestParam Long id
    ) {
        LockerRespVo details = lockerService.getDetails(id);
        return ResultResponse.success(details);
    }

    @PostMapping("/api/wms/locker/add")
    @Operation(summary = "添加智能柜信息")
    public ResultResponse<ResultResponseEnum> add(
            @RequestBody LockerReqVo reqVo
    ) {
        lockerService.add(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/wms/locker/update")
    @Operation(summary = "修改智能柜信息")
    public ResultResponse<ResultResponseEnum> update(
            @RequestBody LockerReqVo reqVo
    ) {
        lockerService.updateById(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/wms/locker/delete")
    @Operation(summary = "删除智能柜信息")
    public ResultResponse<ResultResponseEnum> deleteById(
            @RequestBody PrimaryKeyReqVo reqVo
    ) {
        lockerService.delete(reqVo.getId());
        return ResultResponse.success();
    }

    @GetMapping("/api/wms/locker/getLockerExt")
    @Operation(summary = "获取柜体设置信息")
    public ResultResponse<LockerExtRespVo> getLockerExt(
            @RequestParam String code
    ) {
        LockerExtRespVo lockerExtByCode = lockerService.getLockerExtByCode(code);
        return ResultResponse.success(lockerExtByCode);
    }

    @PostMapping("/api/wms/locker/configLockerExt")
    @Operation(summary = "配置柜体设置信息")
    public ResultResponse<ResultResponseEnum> configLockerExt(
            @RequestBody LockerExtReqVo reqVo
    ) {
        lockerService.configLockerExt(reqVo);
        return ResultResponse.success();
    }


}

